package com.demo.sso.client.config;

import com.demo.sso.sdk.config.SsoSdkProperties;
import com.demo.sso.sdk.interceptor.SsoLoginInterceptor;
import com.demo.sso.sdk.service.SsoClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/login").setViewName("redirect:/sso/login");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注意：这里不直接注入SsoClientService，而是在需要时通过方法参数获取
        // 这样可以避免循环依赖和加载顺序问题
    }
}